import VueRouter from 'vue-router'
import vue from 'vue'

const home = () => import('../pages/Home')
const homoPeople = () => import('../pages/Home/Home_people')
const about = () => import('../pages/About')

// 安装插件
vue.use(VueRouter)

// 创建VueRouter对象
const routes = [{
    path: '/',
    component: home,
    redirect: () => {
        return '/home'
    }
}, {
    path: '/home',
    name: '首页',
    component: home,
    children: [{
        path: 'people',
        component: homoPeople,
    }]
}, {
    path: '/about',
    name: 'about',
    component: about
}]

// 将router对象暴露
const router = new VueRouter({
    routes
})

router.beforeEach((to, from, next) => {
    console.log('to', to);
    console.log('from', from);
    next()
})

export default router